import * as cusPropsService from '../../services/design/cusPropsServices';
import { notification } from 'antd';
export default {
    namespace: 'cusProps',
    state: {
      
    },
    reducers: {
        
    },
    effects: {
        *cusPropsList({ payload:  params  }, { call, put }) {
            const res = yield call(cusPropsService.cusPropsList, { ...params });
            return res&&res.data&&res.data.code=="200"?res.data.data:[]
        },
        *addCusProps({ payload:  {values,onSuccess,onError}  }, { call, put }) {
            const res = yield call(cusPropsService.addCusProps, { ...values });
            if(res&&res.data&&res.data.code=="200"){
                notification.info({ message: "添加自定义属性成功" });
                onSuccess(res);
            }else{
                onError(res && res.data ? res.data.message : '服务器连接失败');
            }
        },
        *deleteCusProps({ payload:  {values,onSuccess,onError}  }, { call, put }) {
            const res = yield call(cusPropsService.deleteCusProps, { ...values });
            if(res&&res.data&&res.data.code=="200"){
                notification.info({ message: "删除自定义属性成功" });
                onSuccess(res.data.data);
            }else{
                onError(res && res.data ? res.data.message : '服务器连接失败');
            }
        },
        *editCusProps({ payload:  {values,onSuccess,onError}  }, { call, put }) {
            const res = yield call(cusPropsService.editCusProps, { ...values });
            if(res&&res.data&&res.data.code=="200"){
                notification.info({ message: "修改自定义属性成功" });
                onSuccess(res.data.data);
            }else{
                onError(res && res.data ? res.data.message : '服务器连接失败');
            }
        },
    }
}